package ml.iray.bean;

import ml.iray.bean.exception.ArgsTooLongException;

/**
 * Created by boot on 12/15/15.
 */
public class TreeEntity extends AbstractCode implements ITreeEntity {
    private String name;
    private int index;
    private boolean leaf;
    private ITreeEntity parent;

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        if (null == name && name.length() > BeanConstant.CODE_MAX_LENGTH) {
            throw new ArgsTooLongException();
        } else {
            this.name = name;
        }
    }

    @Override
    public boolean isLeaf() {
        return this.leaf;
    }

    @Override
    public void setLeaf(boolean leaf) {
        this.leaf = leaf;
    }


    @Override
    public int getIndex() {
        return this.index;
    }

    @Override
    public void setIndex(int index) {
        this.index = index;
    }

    @Override
    public ITreeEntity getParent() {
        return this.parent;
    }


    @Override
    public void setParent(ITreeEntity entity) {
        if (entity instanceof TreeEntity)
            this.parent = entity;
    }

}
